package com.bt.dmdb.controller.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.bt.dmdb.controller.ProjectController;
import com.bt.dmdb.model.Project;
import com.bt.dmdb.service.ProjectService;

@Controller
@RequestMapping("project")
public class ProjectControllerImpl implements ProjectController {

    @Autowired
    private ProjectService projectService;

    @RequestMapping(value = { "/", "" })
    public String ui() {
        return "project/Create";
    }

    @RequestMapping(value = "create", method = RequestMethod.POST)
    @ResponseBody
    public long create(@RequestBody Project project) {
        return projectService.create(project);
    }

    @RequestMapping(value = "search", method = RequestMethod.POST)
    @ResponseBody
    public Project getProject(@RequestParam long id) {
        return projectService.getProject(id);
    }

    public ProjectService getProjectService() {
        return projectService;
    }

    public void setProjectService(ProjectService projectService) {
        this.projectService = projectService;
    }
}
